const { DataTypes, Sequelize } = require('sequelize');
const { sequelize } = require('../database');
const { v4: uuidv4 } = require('uuid');

const ComProducts = sequelize.define('com_products', {
    productName: {
      type: DataTypes.STRING(64),
      field: 'product_name',
      allowNull: false,
      comment: "商品名"
    },

    id: {
      type: DataTypes.BIGINT,
      field: 'id',
      primaryKey: true,
      allowNull: false,
      autoIncrement: true,
      comment: "id"
    },

    createTime: {
      type: DataTypes.DATE,
      field: 'create_time',
      allowNull: false,
      comment: "创建日期"
    },

    brandName: {
      type: DataTypes.STRING(64),
      field: 'brand_name',
      allowNull: false,
      comment: "品牌名"
    },

    brandId: {
      type: DataTypes.BIGINT,
      field: 'brand_id',
      comment: "品牌id"
    },

    updateTime: {
      type: DataTypes.DATE,
      field: 'update_time',
      comment: "更新时间"
    },

    type: {
      type: DataTypes.INTEGER,
      field: 'type',
      allowNull: false,
      comment: "类型（1帐篷 2充气床）"
    },

    remark: {
      type: DataTypes.STRING(500),
      field: 'remark',
      defaultValue: "",
      comment: "备注信息"
    },

    isEnable: {
      type: DataTypes.INTEGER,
      field: 'is_enable',
      allowNull: false,
      defaultValue: "1",
      comment: "状态（0正常 1禁用）"
    },

    status: {
      type: DataTypes.INTEGER,
      field: 'status',
      allowNull: false,
      defaultValue: "0",
      comment: "状态（0正常 2删除）"
    }
}, {
  tableName: 'com_products',
  timestamps: false,
  underscored: true,  // 启用字段映射
  freezeTableName: true  // 固定表名
});

module.exports = ComProducts;